package com.ima.web.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Example;
import org.hibernate.sql.JoinType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ima.web.beans.db.SubCategories;
import com.ima.web.beans.db.UserRoles;
import com.ima.web.dao.UserRolesDao;

@Repository
public class UserRolesDaoImpl implements UserRolesDao{

	private SessionFactory sessionFactory;
	
	@Autowired
	public void setDependencies(SessionFactory sessionFactory){
		this.sessionFactory = sessionFactory;
	}
	
	@Override
	public void save(UserRoles data) {
		Session s = sessionFactory.getCurrentSession();
		s.save(data);
	}

	@Override
	public void delete(UserRoles data) {
		
	}

	@Override
	public List<UserRoles> list(UserRoles data) {
		Session s = sessionFactory.getCurrentSession();
		Criteria c = s.createCriteria(UserRoles.class);
		c.add(Example.create(data));
		
		List<UserRoles> ur = c.list();

		return ur;
	}

	@Override
	public UserRoles findById(int id) {
		// TODO Auto-generated method stub
		return null;
	}

}
